// pages/my/dispatchorder/dispatchorder.js
Page({
  data: {
    list: [],
    page: 1,
    size: 10,
    isNoMore: true,
    isLoding: true
  },
  onLoad: function (options) {
    this.getList();
  },
  onShow: function () {},
  onShareAppMessage() {},
  reset() {
    this.setData({
      list: [],
      page: 1,
      size: 10,
      isNoMore: true,
      isLoding: true
    });
    this.getList();
  },
  onPullDownRefresh() {
    wx.showNavigationBarLoading();
    this.reset();
  },
  getList() {
    let params = {
      page: this.data.page,
      size: this.data.size,
    }
    getApp().globalData.http.myPost(params).then(res => {
      let data_tmp = [...this.data.list, ...res.data];
      this.setData({
        list: data_tmp,
        isLoding: true
      });
      if (this.data.list.length == res.count) {
        this.setData({
          isNoMore: false
        });
      }
      wx.stopPullDownRefresh();
      wx.hideNavigationBarLoading();
    });
  },
  onReachBottom() {
    if (this.data.isNoMore) {
      this.setData({
        page: this.data.page / 1 + 1,
        isLoding: false
      });
      this.getList();
    }
  },
  toDetail(e) {
    wx.navigateTo({
      url: "/pages/my/dispatchorderdetail/dispatchorderdetail?id=" + e.currentTarget.dataset.id,
    });
  }
})